<template>
  <view class="container">
    <!-- 顶部组件 -->
    <u-navbar
      :is-back="true"
      :background="{ background: '#fff' }"
      border-bottom
      id="nav-bar"
      :title="title"
    ></u-navbar>
    <rich-text
      class="richBox"
      :nodes="agreement"
    ></rich-text>
  </view>
</template>
<script>
import service from '@/common/service.js';
export default {
  data() {
    return {
      title: '',
      agreement: ''
    };
  },
  onLoad(e) {
    this.title = e.title;
    let type = Number(e.type);
    if (type === 0) {
      this.getUserAgreement();
    } else if (type === 1) {
      this.getPrivacyPolicy();
    }
  },
  methods: {
    getUserAgreement() {
      const that = this;
      service.getUserAgreement(
        {},
        function (res) {
          if (res && res.status === 1) {
            const { data } = res;
            that.agreement = data;
          }
        },
        function () {}
      );
    },
    getPrivacyPolicy() {
      const that = this;
      service.getPrivacyPolicy(
        {},
        function (res) {
          if (res && res.status === 1) {
            const { data } = res;
            that.agreement = data;
          }
        },
        function () {}
      );
    }
  }
};
</script>

<style lang="scss">
page {
  background-color: #fff;
}

.container {
  width: 100%;
  min-height: 100vh;
  padding: 0 30rpx 60rpx;
  text-align: left;
  background-color: #fff;
}

.richBox {
  width: 100%;
}
</style>
